

class CustomException {
  CustomException({this.code,this.msg,this.exception, this.interfaceCode});

  int? interfaceCode;
  int? code;
  String? msg;
  Exception? exception;


  @override
  String toString() {
    return 'CustomException{interfaceCode: $interfaceCode, code: $code, msg: $msg, exception: $exception}';
  }

  static var notInitException = CustomException(code: 2001, msg: "模块未初始化！");
  static var nullContextException = CustomException(code: 2002, msg: "Context为空！");
  static var appContextException = CustomException(code: 2003, msg: "context必须为Activity！");
  static var activityDestroyException = CustomException(code: 2004, msg: "Activity已销毁！");

  static CustomException interfaceException(int? interfaceCode, String? msg) {
    return CustomException(code: 3000, msg: msg, interfaceCode: interfaceCode);
  }

  static CustomException interfaceException1(int? interfaceCode) {
    return CustomException(code: interfaceCode, msg: "接口异常");
  }

  static CustomException netException(Exception? exception) {
    return CustomException(code: 1001, msg: "网络错误！", exception: exception);
  }

  static CustomException httpCodeErrorException(int? interfaceCode) {
    return CustomException(code: 1002, msg: "Http状态码错误", interfaceCode: interfaceCode);
  }

  static CustomException downloadException(Exception? exception) {
    return CustomException(code: 1003, msg: "下载错误", exception: exception);
  }
}
